package cz.kfad.ofrss.activity;


import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.actionbarsherlock.app.SherlockActivity;

import cz.kfad.ofrss.R;
import cz.kfad.ofrss.common.ApplicationContext;
import cz.kfad.ofrss.synchronization.SyncScheduler;


public class StartActivity extends SherlockActivity {


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

		setTitle(R.string.start_title);

		final Button buttonToAll = (Button) findViewById(R.id.main_to_all);
		buttonToAll.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View view) {
				startActivity(new Intent(StartActivity.this, AllFeedsActivity.class));
			}
		});

        final Button buttonToCategories = (Button) findViewById(R.id.main_to_categories);
        buttonToCategories.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                final Intent intent = new Intent(StartActivity.this, CategoriesActivity.class);
                startActivity(intent);
            }
        });

        final Button buttonToChannels = (Button) findViewById(R.id.main_to_channel);
        buttonToChannels.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(StartActivity.this, ChannelsActivity.class));
            }
        });

        final Button buttonToPreferences = (Button) findViewById(R.id.main_to_pref);
        buttonToPreferences.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(StartActivity.this, OFRSSPreferenceActivity.class));
            }
        });
        
        	
		// final DevelopmentDatabaseHelper developmentDatabaseHelper = new DevelopmentDatabaseHelper(this);
		// developmentDatabaseHelper.removeAllRssFeed();
		// developmentDatabaseHelper.removeAllChannels();
		// developmentDatabaseHelper.removeAllCategories();

		// final Channel aktualneChannel = new Channel(1, "Aktualne.cz", 2, 0, "http://aktualne.centrum.cz/feeds/rss/kultura/?photo=1");
		// final Channel novinkyChannel = new Channel(5, "Novinky.cz", 1, 1, "http://www.novinky.cz/rss2/internet-a-pc/");
		//
		// final Category category = new Category(4, "Categroy1", 1, 1, "Categroy1");
		// final Category category1 = new Category(8, "Categroy2", 1, 1, "Categroy2");
		// final Category category2 = new Category(8, "hleda ale", 1, 1, "ale");

		// final DatabaseHelper databaseHelper = new DatabaseHelper(this);
		//
		// databaseHelper.saveChannel(aktualneChannel);
		// databaseHelper.saveChannel(novinkyChannel);
		//
		// databaseHelper.saveCategory(category);
		// databaseHelper.saveCategory(category1);
		// databaseHelper.saveCategory(category2);

		startScheduler();

    }

	private void startScheduler() {
		Intent service = new Intent(this, SyncScheduler.class);
		this.sendBroadcast(service);
	}

	@Override
	protected void onResume() {
		super.onResume();
		ApplicationContext appState = ((ApplicationContext) getApplicationContext());
		appState.setContextToAsynTasks(this);
	}
}